package leetcode.editor.cn.weekly

class Week49 {
    fun truncateSentence(s: String, k: Int): String {
        var count = 0
        s.forEachIndexed { index, c ->
            if (c == ' ') {
                count++
                if (count==k)
                    return s.substring(0,index)
            }
        }
        return s
    }
}